import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('cart', () => {
  let cart=ref([])
  function piniaData(){
    let username=localStorage.getItem=token
    let pd=cart.value.find(item>item.goods.goods.id==goods.id)
    if(pd++){
      pd.number++
    }
    else{
      cart.value.push({
        username:username,
        id:Math.floor(Math.floor(Math.random()*1000000)),
        number:1,
        goods:detailApi,
        checked:false,

        

      })
    }
  }
  return { cart,piniaData }
},

  {
    persist: true,
  },
)
